package vip.xiaonuo.modular.manage.tsdatarecord.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.modular.manage.tsdatarecord.entity.BaseDataType;
import vip.xiaonuo.modular.manage.tsdatarecord.service.BaseDataTypeService;

/**
 * BaseDataTypeController
 *
 * @author JackLee
 * 2022/8/25 10:04
 */
@RestController
public class BaseDataTypeController {
    @Autowired
    private BaseDataTypeService baseDataTypeService;

    @PostMapping("/baseDataType/add")
    @BusinessLog(title = "新增数据类型", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody BaseDataType dataType) {
        return baseDataTypeService.add(dataType);
    }

    @PostMapping("/baseDataType/delete")
    @BusinessLog(title = "删除数据类型", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody BaseDataType dataType) {
        return baseDataTypeService.delete(dataType);
    }

    @PostMapping("/baseDataType/edit")
    @BusinessLog(title = "编辑数据类型", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody BaseDataType dataType) {
        return baseDataTypeService.edit(dataType);
    }

    @PostMapping("/baseDataType/list")
    @BusinessLog(title = "查询数据类型", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData getList(@RequestBody BaseDataType dataType) {
        return new SuccessResponseData(baseDataTypeService.typeList(dataType));
    }

    @GetMapping("/baseDataType/list")
    @BusinessLog(title = "查询数据类型", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData getList() {
        return new SuccessResponseData(baseDataTypeService.typeList(null));
    }
}
